﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;

namespace WebApplication1
{
    public partial class WebForm9 : System.Web.UI.Page
    {
        string empid;
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Visible = false;
            Label2.Visible = false;
            TextBox1.Visible = false;
            TextBox2.Visible = false;
            this.Label3.Text = Request.QueryString["empname"];
            empid = Request.QueryString["eid"];
        }

        protected void home_Click(object sender, EventArgs e)
        {
            Response.Redirect("http://localhost:62505/Default.aspx");
        }
        private OleDbConnection accessconn;
        //shows the shift time and job type for the selected date if there is one
        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            accessconn = new OleDbConnection();
            accessconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                                @"C:\Dbase_SEA\myDB.accdb";
            string sel_date =  Calendar1.SelectedDate.Date.ToString();
            string query10 = "select * from Schedule where Eid = '" + empid + "';";
            DataSet ds = new DataSet();
            accessconn.Open();
            OleDbDataAdapter da = new OleDbDataAdapter(query10,accessconn);
            da.Fill(ds);
            bool stat = false;
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                //System.Diagnostics.Debug.Write(sel_date);
                //System.Diagnostics.Debug.Write(ds.Tables[0].Rows[i]["ShiftDate"].ToString());
                if (sel_date == ds.Tables[0].Rows[i]["ShiftDate"].ToString())
                {
                    stat = true;
                    TextBox1.Text = ds.Tables[0].Rows[0]["ShiftTime"].ToString();
                    TextBox2.Text = ds.Tables[0].Rows[0]["JobType"].ToString();
                    Label1.Visible = true;
                    Label2.Visible = true;
                    TextBox1.Visible = true;
                    TextBox2.Visible = true;
                }
            }
            if (stat == false)
                MessageBox("Happy Holiday");
        }
        private void MessageBox(string msg)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
            Page.Controls.Add(lbl);
        }
    }
}
